bin=httpserver
cc=g++
curr=$(shell pwd)
LD_FLAGS=-std=c++11 -lpthread
src=main.cc


ALL:$(bin) CGI
.PHONY:ALL

$(bin):$(src) 
	$(cc) -o $@ $^ $(LD_FLAGS)

CGI:
	cd $(curr)/cgi;\
	make clean;\
	make;\
	cd -

.PHONY:clean
clean:
	rm -rf $(bin);\
	rm -rf output;\
	cd $(curr)/cgi;\
	make clean

.PHONY:output
output:
	mkdir -p output;\
	cp $(bin) output;\
	cp -rf wwwroot output;\
	cp ./cgi/test_cgi output/wwwroot;\
	cp ./cgi/mysql_cgi output/wwwroot